<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>sentox-DateBox</title>
		<link type="text/css" rel="stylesheet" href="../css/themes/sentox/easyui.css" />
		<link type="text/css" rel="stylesheet" href="../css/themes/sentox/font-awesome.min.css">

		<script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
	</head>

	<body style="margin:10px;">
		<h2>Shared Calendar in DateBox</h2>
		<p>Multiple datebox components can share a calendar and use it to pick dates.</p>
		<div style="margin:20px 0;"></div>
		<table>
			<tr>
				<td>Start Date:</td>
				<td>
					<input class="easyui-datebox" data-options="sharedCalendar:'#cc'">
				</td>
				<td>End Date:</td>
				<td>
					<input class="easyui-datebox" data-options="sharedCalendar:'#cc'">
				</td>
			</tr>
		</table>
		<div id="cc" class="easyui-calendar"></div>
		<!----------------------------------------------------------------------------------------------------------------------------->
		
		<h2>Validate DateBox</h2>
		<p>When the selected date is greater than specified date. The field validator will raise an error.</p>
		<div style="margin:20px 0;"></div>
		<input class="easyui-datebox" required data-options="validType:'md[\'10/11/2012\']'"></input>
		<script>
			$.extend($.fn.validatebox.defaults.rules, {
				md: {
					validator: function(value, param){
						var d1 = $.fn.datebox.defaults.parser(param[0]);
						var d2 = $.fn.datebox.defaults.parser(value);
						return d2<=d1;
					},
					message: 'The date must be less than or equals to {0}.'
				}
			})
		</script>
		<!----------------------------------------------------------------------------------------------------------------------------->
		
		<h2>DateBox Events</h2>
		<p>Click the calendar image on the right side.</p>
		<div style="margin:20px 0;"></div>
		<input class="easyui-datebox" data-options="onSelect:onSelect"></input>
		<div style="margin:10px 0">
			<span>Selected Date: </span>
			<span id="result"></span>
		</div>
		<script>
			function onSelect(date){
				$('#result').text(date)
			}
		</script>
		<!----------------------------------------------------------------------------------------------------------------------------->
		
		<h2>Restrict Date Range in DateBox</h2>
		<p>This example shows how to restrict the user to select only ten days from now.</p>
		<div style="margin:20px 0;"></div>
		<input id="dd"></input>
		<script>
			$(function(){
				$('#dd').datebox().datebox('calendar').calendar({
					validator: function(date){
						var now = new Date();
						var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
						var d2 = new Date(now.getFullYear(), now.getMonth(), now.getDate()+10);
						return d1<=date && date<=d2;
					}
				});
			});
		</script>
		<!----------------------------------------------------------------------------------------------------------------------------->
		
		<h2>DateBox Buttons</h2>
		<p>This example shows how to customize the datebox buttons underneath the calendar.</p>
		<div style="margin:20px 0;"></div>
		<input class="easyui-datebox"></input>
		<input class="easyui-datebox" data-options="buttons:buttons"></input>
		<script>
			var buttons = $.extend([], $.fn.datebox.defaults.buttons);
			buttons.splice(1, 0, {
				text: 'MyBtn',
				handler: function(target){
					alert('click MyBtn');
				}
			});
		</script>
		
		<!----------------------------------------------------------------------------------------------------------------------------->
		
	</body>

</html>